package com.design.controller.web;


import com.design.dao.entity.Container;
import com.design.model.BaseResult;
import com.design.model.PageResult;
import com.design.service.ContainerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "【WEB端-集装箱管理】")
@RequestMapping("/container")
@CrossOrigin(origins = "*")
public class ContainerController {

    @Autowired
    private ContainerService containerService;

    @ApiOperation(value = "集装箱管理-查询集装箱列表")
    @GetMapping("/queryByPage")
    public PageResult<List<Container>> queryByPage(String templateNum, Integer pageNum, Integer pageSize) {
        return containerService.queryByPage(templateNum, pageNum, pageSize);
    }

    @ApiOperation(value = "集装箱管理-新增/编辑集装箱")
    @PostMapping("/edit")
    public BaseResult<Void> edit(@RequestBody Container container) {
        containerService.edit(container);
        return new BaseResult<>();
    }

    @ApiOperation(value = "集装箱管理-删除集装箱")
    @PostMapping("/remove")
    public BaseResult<Void> remove(@RequestBody Map<String,Integer> map) {
        containerService.remove(map.get("id"));
        return new BaseResult<>();
    }

}
